package 集合;

import java.util.*;

public class 双列集合 {
    public static void main(String[] args) {
        Map<String,Integer> map=new HashMap<>();
        map.put("euryg",1);
        map.put("wq",2);
        map.put("wq",3);
        map.put("wq",0);
        System.out.println(map);
//        treemap按照键生序排序
        Map<String,Integer> map1=new TreeMap<>(String::compareTo);
        map1.put("euryg",1);
        map1.put("wq",2);
        map1.put("wq",3);
        map1.put("wq",0);
        map1.put("rgr",0);
        map1.put("rherher",0);
        System.out.println(map1);
        System.out.println(map1.containsKey("euryg"));
        System.out.println(map1.containsValue(0));
        Set<String> strings = map1.keySet();
        System.out.println(strings);
        Collection<Integer> values = map1.values();
        System.out.println(map.remove("wq"));
        Set<Map.Entry<String, Integer>> entries = map1.entrySet();
        for (Map.Entry<String, Integer> entry : entries) {
            System.out.println(entry.getKey()+" "+entry.getValue());
        }
        Map<String, Integer> map2 = new HashMap<>();
        map2.putAll(map1);
        System.out.println(map2);
        map2.forEach(
                (key,value)->System.out.println(key+" "+value)
        );
        for(Map.Entry<String,Integer> entry:map2.entrySet()){
            System.out.println(entry.getKey()+" "+entry.getValue());
        }
    }
}
